home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 4.4 KB | 102 lines | [TEXT/GEOL] |
- Item 5083185 25-Jan-91 09:09PST
-
- From: DEREK White, Derek
-
- To: GER.XDV0002 Germany - P1 Ges f Informatik,IVR
- MACAPP.TECH$ MacApp Technical
-
- ------------------------------------------------------------------------------
-
- Sub: re-Operator overloading & C++
-
- Dear Eric,
-
- We will probably always disagree about this, but here it goes.
-
- >...C++ allows you to precisely and succintly define the content of an
- >algorithm or idea in a way that is instantly recognizable to the reader.
-
- This is true iff the semantics of the overloaded operator roughly match the
- semantics of the built-in operator.
-
- ------- Some arguments against general operator overloading ------------
-
- • Most operators don't have unambiguous definitions for most objects.
-
- The only general operators that I can come up with are assignment (:=),
- comparison (=, <>), and perhaps relational comparison (<, <=, >, >=). These
- can be overridden in ways much simpler than adding operator overloading to a
- language (why should I have to overload SIX comparison OPERATORS when I really
- am trying to overload the relational comparison OPERATION?)
-
- The + operator probably comes up as the next most general operator. It can be
- used for various scaler, complex, and matrix math, string concatenation, and
- set unions of all types. But what does + mean for a TView? Add them in a
- list? Take the union of their visRegions? Return the combined sizes of the
- TViews?
-
- What about *? This is even less useful. Consider your matrix example:
- matrix1 = matrix2 + matrix3*matrix4;
- Should the * operator stand for the dot product or the cross product? It's
- ambiguous by looking at the source.
-
- The remaining operators tend to be ridiculous when applied to objects, and the
- language 'feature' only encourages silly programming. The best example of this
- is AT&T's use of the bit shifting operators (<<, >>) to do object I/O! The
- only apparent reason to use those operators is that they weren't used (yet) and
- they looked nice.
-
- • Hiding complexity is not always a good idea.
- Hiding the call of a 100,000 x 100,000 element matrix multiply behind an
- innocuous * can lead you to ignore efficiency considerations. If I'm going to
- something THAT expensive, I want to know about it. That's just me. You
- probably don't, but you've already got your language :-)
-
- >Does the possibility of obfuscation exist? Yes. But that is the nature of
- >most powerful tools, they are double edged swords. Quantum mechanics opened
- >the door to modern electronics and the atom bomb. One is a cornerstone of
- >western civilization and the other is the shadow of doom. Does that mean
- >quantum mechanics is dangerous? No.
-
- If you want to claim that operator overloading is akin to quantum mechanics
- then I think you're hurting your own argument :-)
- [Wild claim coming...]
- I think there are more people that REALLY understand Quantum mechanics than do
- C++, which will have to change if the state of software engineering is not to
- get bogged down for the next 5-10 years.
-
- I've managed to write code dealing with complex numbers and matrices using
- Pascal's normal notation and lived to tell the tale. Sure, it would have been
- cute to overload a couple of operators, but that's not enough reason to add an
- entire language feature that's useless or actually harmful in most instances.
- Most programming doesn't revolve around matrices.
-
- ------- More Random C++ Flames ------------
-
- >What C++ demands of the programmer is a strict design philosophy and adherance
- >to the karma, if you will, of programming.
-
- Actually, C++ demands nothing. But the need to write WORKING C++ programs
- demands a lot of discipline. C++ does little to help you with it though.
-
- >The real danger of “bad code” is a fear of the “untrained hacker” entering
- >the code arena. I assume you are not such a person, and that you would do
- >well.
-
- Everyone was an “untrained hacker” at some point. Much new software is written
- by these people (co-ops, summer students, new hires), because the “old hands”
- are bogged down maintaining old code and can't be pulled away to write the new
- stuff. It scares me that these eager young programmers will be seduced by
- C++'s features and write REALLY BAD code until they learn ALL the discipline
- necessary.
-
-
- Hoping to offer an alternative to C++,
- and something that new O-O programmers can cut their teeth on (besides broken
- glass),
- I remain,
- Yours,
-
- Derek White
-
-